package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TSpCountTax;
import com.ruoyi.system.service.ITSpCountTaxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目税款利润统计Controller
 * 
 * @author ruoyi
 * @date 2024-03-21
 */
@RestController
@RequestMapping("/system/tax")
public class TSpCountTaxController extends BaseController
{
    @Autowired
    private ITSpCountTaxService tSpCountTaxService;

    /**
     * 查询项目税款利润统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:tax:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSpCountTax tSpCountTax)
    {
        startPage();
        List<TSpCountTax> list = tSpCountTaxService.selectTSpCountTaxList(tSpCountTax);
        return getDataTable(list);
    }


    /**
     * 导出项目税款利润统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:tax:export')")
    @Log(title = "项目税款利润统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TSpCountTax tSpCountTax)
    {
        tSpCountTaxService.exportExcel(tSpCountTax,response);
    }


    /**
     * 获取项目税款利润统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tax:query')")
    @GetMapping(value = "/getById")
    public AjaxResult getInfo(TSpCountTax tSpCountTax)
    {
        return success(tSpCountTaxService.selectTSpCountTaxByProjectId(tSpCountTax));
    }

    /**
     * 利润合计
     */
    @PreAuthorize("@ss.hasPermi('system:tax:query')")
    @GetMapping(value = "/profitSum")
    public AjaxResult selectProfitSum(TSpCountTax tSpCountTax)
    {
        return success(tSpCountTaxService.selectProfitSum(tSpCountTax));
    }

    /**
     * 项目金额
     */
    @PreAuthorize("@ss.hasPermi('system:tax:query')")
    @GetMapping(value = "/projectMoney")
    public AjaxResult selectProjectMoney(TSpCountTax tSpCountTax)
    {
        return success(tSpCountTaxService.selectProjectMoney(tSpCountTax));
    }


    /**
     * 新增项目税款利润统计
     */
    @PreAuthorize("@ss.hasPermi('system:tax:add')")
    @Log(title = "项目税款利润统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSpCountTax tSpCountTax)
    {
        return toAjax(tSpCountTaxService.insertTSpCountTax(tSpCountTax));
    }

    /**
     * 修改项目税款利润统计
     */
    @PreAuthorize("@ss.hasPermi('system:tax:edit')")
    @Log(title = "项目税款利润统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSpCountTax tSpCountTax)
    {
        return toAjax(tSpCountTaxService.updateTSpCountTax(tSpCountTax));
    }

    /**
     * 删除项目税款利润统计
     */
    @PreAuthorize("@ss.hasPermi('system:tax:remove')")
    @Log(title = "项目税款利润统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds)
    {
        return toAjax(tSpCountTaxService.deleteTSpCountTaxByProjectIds(projectIds));
    }



    /**
     * 查询项目税款利润统计列表  历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:tax:historylist')")
    @GetMapping("/historylist")
    public TableDataInfo historylist(TSpCountTax tSpCountTax)
    {
        startPage();
        List<TSpCountTax> list = tSpCountTaxService.selectTSpCountTaxListHistory(tSpCountTax);
        return getDataTable(list);
    }


    /**
     * 利润合计  历史记录
     */
//    @PreAuthorize("@ss.hasPermi('system:tax:queryhistory')")
    @GetMapping(value = "/profitSumHistory")
    public AjaxResult profitSumHistory(TSpCountTax tSpCountTax)
    {
        return success(tSpCountTaxService.selectProfitSumHistory(tSpCountTax));
    }


    /**
     * 导出项目税款利润统计列表  历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:tax:exporthistory')")
    @Log(title = "项目税款利润统计历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/exporthistory")
    public void exporthistory(HttpServletResponse response, TSpCountTax tSpCountTax)
    {
        tSpCountTaxService.exportExcelHistory(tSpCountTax,response);
    }


    /**
     * 修改项目税款利润统计 历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:tax:edithistory')")
    @Log(title = "项目税款利润统计历史记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edithistory")
    public AjaxResult edithistory(@RequestBody List<TSpCountTax> list)
    {
        return toAjax(tSpCountTaxService.updateTSpCountTaxHistory(list));
    }
}
